package patternmining.model.graph;

import java.util.Collection;
import java.util.Iterator;
import patternmining.model.construction.Source;
import patternmining.model.construction.bpsl.BpslAstWalker;

public class Graph {

    GraphImplementation implementator;

    public Graph(){
        implementator = new JungImplementation();
    }

    public String toString(){
        return implementator.toString();
    }

    public void add(Vertex vertex) {
        implementator.add(vertex);
    }
	 
    public void add(Edge edge) {
        implementator.add(edge);
    }
    
    public Collection<Vertex> getVertices(){
        return implementator.getVertices();
    }
     public Collection<Vertex> getSuccessors(Vertex vertex){
        return implementator.getSuccessors(vertex);
    }
    
    public boolean containsAsSubgraph(Graph containedGraph){
        boolean contains = false;
        Iterator<Vertex> containedGraphVertices = containedGraph.getVertices().iterator();
        Collection<Vertex> containingGraphVerts = implementator.getVertices();
        Iterator<Vertex> containingGraphVertices;
        Vertex containedGraphVertex;
        Vertex containingGraphVertex;
        while ( !contains && containedGraphVertices.hasNext() ){
            containedGraphVertex = containedGraphVertices.next();
            containingGraphVertices = containingGraphVerts.iterator();
            while ( !contains && containingGraphVertices.hasNext() ){
                containingGraphVertex = containingGraphVertices.next();
                contains = containedGraphVertex.testForSubgraph(containingGraphVertex,this, containedGraph);
            }
        }
        return contains;
    }
    
    public Collection<Edge> getOutEdges(Vertex vertex){
        return implementator.getOutEdges(vertex);
    }
    
    public Edge getEdge(Vertex origin, Vertex destination){
        return implementator.getEdge(origin, destination);
    }
    
    public boolean existsParalellEdge(Edge edge){
        return implementator.existsParalellEdge(edge);
    }
    public Collection<Edge> getParallelEdges(Edge edge){
        return implementator.getParallelEdges(edge);
    }
    
}
 
